<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body style="background-color: #CCEEAA">
<?php
$conn = @mysqli_connect("localhost","root","","abcd");
if (!$conn){
    die("连接数据库失败：" . mysqli_error());
}
@mysql_query("set names 'UTF8'");
//mysql_query('DELETE FROM `bbtliuyanban` WHERE `id` = \'' . $_GET['id'] . '\'');
$a=$_GET['id'];

session_start();
$user =$_SESSION['username'];
$sqlOne="select * from message where id=$a";

$sqlFour="select * from message where id=$a";

$sqlOne=mysqli_query($conn,$sqlOne);

$sqlFour=mysqli_query($conn,$sqlFour);

$sqlFour=mysqli_fetch_array($sqlFour);

$he=$sqlFour['user'];

$sqlOne=@mysqli_fetch_array($sqlOne);

$sqlThree="select * from huifu where id=$a";
$sqlThree=mysqli_query($conn,$sqlThree);
header('Content-type:text/html;charset=utf-8');
if(isset($_POST['submit']))
{
    if($sqlFour['sheji']==0)
    {
        echo "<script language='javascript'>alert(sqlFive['sheji']);</script>";
        $content=$_POST['textarea'];
        $sqlTwo="insert into huifu(id,username,content) VALUES ($a,'$user','$content')";
        $ab=mysqli_query($conn,$sqlTwo);
        if(!$ab)
        {
            echo "<script language='javascript'>alert('请返回后重新回复');</script>";
        }
        else{
            $a=$_SESSION['username'];
            $jifen="select jifen from user where username='$a'";
            $jifen=mysqli_query($conn,$jifen);
            $jifen=mysqli_fetch_row($jifen);
            $jifen=$jifen[0]+1;
            $jifenTwo="update user set jifen=jifen+1 WHERE username='$a'";
            mysqli_query($conn,$jifenTwo);
            echo "<script language='javascript'>alert('回复成功，增加一个积分，您当前的积分为'+$jifen);history.go(-1);</script>";
        }
    }
    else{
        echo "<script language='javascript'>alert('该帖已禁止评论');history.go(-1);</script>";
    }
}
?>
<div style="width: 700px;margin: 0 auto;border: 3px solid #19B955;min-height: 700px;text-align: center">
    <p style="width: 400px;font-size: 20px;margin:0 auto;border-bottom: 1px dashed grey;text-align: center;height: 60px;line-height: 60px"><?php echo $sqlOne['title'];?></p>
    <p style="width: 200px;font-size: 14px;color: darkgrey;margin:0 auto;"><?php echo $sqlOne['lastdate'];?></p>
    <p style="width: 400px;font-size: 18px;margin:0 auto;"><?php echo $sqlOne['content']?></p>
    <form method="post" action="huitie.php?id=<?php echo $a?>" onsubmit="return inputCheck(this)">
        <textarea  cols="40" rows="6" name="textarea"></textarea>
        <input type="submit" value="回复" style="background-color: #6067c1;color: white" name="submit"/>
    </form>

    <div style="width: 450px;text-align: left;margin: 0 auto;">
        <ul>
            <?php
            while ($row=mysqli_fetch_array($sqlThree)) {
            ?>
                <li style="list-style: none"><p style="font-size: 15px;color: blue"><?php echo $row['username']?>回复<?php echo $he?></p>
                    <p style="color: darkgrey"><?php echo $row['time']?></p>
                    <p style="font-size: 15px"><?php echo $row['content']?></p>
                </li>
            <?php
            }
            ?>
        </ul>
    </div>
</div>
</body>
</html>
<script>
    function inputCheck(logoForm) {
        if(logoForm.textarea.value=="")
        {
            alert('内容不能为空');
            logoForm.textarea.focus();
            return false;
        }
    }
</script>